package hot100;

import DTO.TreeNode;

public class maxDepth2 {
    int ret;
    public int maxDepth(TreeNode root) {
        ret = 0;
        dfs(root,1);
        return ret;
    }
    public void dfs(TreeNode root,int temp) {
        if(root != null) {
            if(ret < temp) {
                ret = temp;
            }
        }
        if(root == null) {
            return;
        }
        dfs(root.left,temp + 1);
        dfs(root.right,temp + 1);
    }
}
